<?php
	class EnsembleDeDepartements {
		
		var $departements;
		var $selected;
		
		function EnsembleDeDepartements($selected=NULL){
			$this->departements = array();
			$this->selected = $selected;
			$departements = $GLOBALS['PHPFoxEngine']->database->query("SELECT id_departement,nom_departement,code FROM departements ORDER BY code ASC");
			while($departement = mysql_fetch_assoc($departements)){
				$this->departements[$departement['id_departement']] = $departement['code'].' - '.$departement['nom_departement'];
			}
		}
		
		function makeOptions(){
			$select='';
			foreach($this->departements as $key => $value){
				$select .= ($this->selected == $key)? '<option selected="selected" id="'.$key.'" value="'.$key.'">'.$value.'</option>':'<option id="'.$key.'" value="'.$key.'">'.$value.'</option>';	
			}
			return $select;
		}
		
		
	}
?>